home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / oop_tp55.zip / LIST5_6.PAS < prev    next >
Pascal/Delphi Source File  |  1990-02-01  |  2KB  |  93 lines

  1. program Listing5_6;
  2.  
  3. type
  4.  
  5. Person = ( fps, sps, tps, fpp, spp, tpp );
  6. Ending = array[fps..tpp] of string;
  7.  
  8. const
  9. ER_Nominative : Ending
  10.                         = ( 'e', 'es', 'e', 'ons', 'ez', 'ent' );
  11. IR_Nominative : Ending
  12.             = ( 'is', 'is', 'it', 'issons', 'issez', 'issent');
  13. RE_Nominative : Ending
  14.             = ( 's', 's', '', 'ons', 'ez', 'ent');
  15.  
  16. type
  17. Verb = object
  18.        Infinitive : string;
  19.        Root       : string;
  20.        constructor Init( TheVerb : string );
  21.        function VerbForm( E : Person ) : string; virtual;
  22.        procedure ConjugateVerb;
  23.        end;
  24.  
  25. RE_Verb = object( Verb )
  26.           function VerbForm( E : Person ) : string; virtual;
  27.       end;
  28.  
  29.  
  30. IR_Verb = object( Verb )
  31.           function VerbForm( E : Person ) : string; virtual;
  32.       end;
  33.  
  34. ER_Verb = object( Verb )
  35.           function VerbForm( E : Person ) : string; virtual;
  36.       end;
  37.  
  38. constructor Verb.Init( TheVerb : string );
  39. begin
  40.      Infinitive := TheVerb;
  41.      Root := Copy( TheVerb, 1, (Length(TheVerb) - 2) );
  42. end;
  43.  
  44. { This function is needed to be able to compile the .ConjugateVerb
  45.   method }
  46. function Verb.VerbForm( E: Person ) : string;
  47. begin
  48.      VerbForm := '';
  49. end;
  50.  
  51. function ER_Verb.VerbForm( E : Person ) : string;
  52. begin
  53.      VerbForm := Concat( Root, ER_Nominative[E] )
  54. end;
  55.  
  56. function IR_Verb.VerbForm( E : Person ) : string;
  57. begin
  58.      VerbForm := Concat( Root, IR_Nominative[E] )
  59. end;
  60.  
  61. function RE_Verb.VerbForm( E : Person ) : string;
  62. begin
  63.      VerbForm := Concat( Root, RE_Nominative[E] )
  64. end;
  65.  
  66. procedure Verb.ConjugateVerb;
  67. begin
  68.      writeln( 'Conjugation of the verb ', Infinitive, ':' );
  69.      writeln( 'je ', VerbForm( fps ) );
  70.      writeln( 'tu ', VerbForm( sps ) );
  71.      writeln( 'il ', VerbForm( tps ) );
  72.      writeln( 'nous ', VerbForm( fpp ) );
  73.      writeln( 'vous ', VerbForm( spp ) );
  74.      writeln( 'ils ', VerbForm( tpp ) );
  75. end;
  76.  
  77. var
  78.    repondre : RE_Verb;
  79.    finir   : IR_Verb;
  80.    manquer  : ER_Verb;
  81. begin
  82.      repondre.Init( 'repondre' );
  83.      finir.Init( 'finir' );
  84.      manquer.Init( 'manquer' );
  85.  
  86.      repondre.ConjugateVerb;
  87.      finir.ConjugateVerb;
  88.      manquer.ConjugateVerb;
  89.  
  90. end.
  91.  
  92.  { Listing 5-6 }
  93.